From: Olaf Hering Date: Mon, 26 Mar 2012 13:22:18 +0000 (+0200) Subject: tools/libxc: send page-in requests in batches in linux_privcmd_map_foreign_bulk X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22man:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22man:/?a=commitdiff_plain;h=98901586719af81409ffbd8ca0112a0685b360a6;p=xen.git tools/libxc: send page-in requests in batches in linux_privcmd_map_foreign_bulk One of the bottlenecks with foreign page-in request is the poor retry handling in linux_privcmd_map_foreign_bulk(). It sends one request per paged gfn at a time and it waits until the gfn is accessible. This causes long delays in mmap requests from qemu-dm and xc_save. Instead of sending one request at a time, walk the entire gfn list and send batches of mmap requests. They will eventually end up in the pager's request ring (if it has room again), and will fill up this ring so that in turn the pager can also process page-in in batches. Signed-off-by: Olaf Hering Committed-by: Ian Jackson --- diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c index 896f5c1356..744dfea80d 100644 --- a/tools/libxc/xc_linux_osdep.c +++ b/tools/libxc/xc_linux_osdep.c @@ -191,6 +191,59 @@ static void *linux_privcmd_map_foreign_batch(xc_interface *xch, xc_osdep_handle return addr; } +/* + * Retry mmap of all paged gfns in batches + * retuns < 0 on fatal error + * returns 0 if all gfns left paging state + * returns > 0 if some gfns are still in paging state + * + * Walk all gfns and try to assemble blocks of gfns in paging state. + * This will keep the request ring full and avoids delays. + */ +static int retry_paged(int fd, uint32_t dom, void *addr, + const xen_pfn_t *arr, int *err, unsigned int num) +{ + privcmd_mmapbatch_v2_t ioctlx; + int rc, paged = 0, i = 0; + + do + { + /* Skip gfns not in paging state */ + if ( err[i] != -ENOENT ) + { + i++; + continue; + } + + paged++; + + /* At least one gfn is still in paging state */ + ioctlx.num = 1; + ioctlx.dom = dom; + ioctlx.addr = (unsigned long)addr + ((unsigned long)i< 0 ); } /* Command was not recognized, use fall back */ else if ( rc < 0 && errno == EINVAL && (int)num > 0 )